package com.ch.engine.daily.abstractTest;

/**
 * 微信支付 - 继承抽象类并实现接口
 *
 * @author wangchunhui
 * @date 2025/8/6 17:40
 */
public class WeChatPay extends AbstractPaymentProcessor implements PaymentInterface, NotificationInterface {
    
    public WeChatPay() {
        super("微信支付", 0.001); // 0.1%手续费
    }
    
    // 实现抽象类的抽象方法
    @Override
    protected boolean doPayment(double amount) {
        System.out.println("连接微信支付服务器...");
        System.out.println("微信支付完成");
        return true;
    }
    
    // 实现PaymentInterface接口
    @Override
    public boolean processPayment(double amount) {
        validateAmount(amount);
        return executePayment(amount);
    }
    
    // 实现NotificationInterface接口
    @Override
    public void sendNotification(String message) {
        System.out.println("微信通知：" + message);
    }
    
    // 重写钩子方法
    @Override
    protected void afterPaymentSuccess(double amount) {
        sendSuccessNotification(amount);
        if (amount > 100) {
            System.out.println("获得微信红包奖励！");
        }
    }
}
